package com.project.BSCG1;

import java.util.ArrayList;

import org.junit.Test;
import static org.junit.Assert.*;

public class GameTest{
	
	@Test
	public void testCard(){
		Card c = new Card("A");
		assertEquals("A", c.getAminoAcid());
		c.setAminoAcid("F");
		assertEquals("F", c.getAminoAcid());
		c.setAminoAcid("Z");
		assertEquals("Z", c.getAminoAcid());
	}
	
	@Test
	public void testHand(){
		Hand h = new Hand();
		Card c = new Card("A");
		h.addCard(c);
		assertEquals(c, h.getCard(0));
		Card c2 = new Card("Z");
		assertEquals(c, h.replaceCard(c2, 0));
		assertEquals(c2, h.getCard(0));
		assertFalse(h.getCardTurn(0));
		h.setCardTurn(0);
		assertTrue(h.getCardTurn(0));
		assertEquals(1, h.size());
	}
	
	@Test
	public void testScore(){
		Score score = new Score();
		Hand h = new Hand();
		Player p = new Player("", 0);
		Card c1 = new Card("V");
		Card c2 = new Card("A");
		h.addCard(c1);
		h.addCard(c2);
		p.setPlayersHand(h);
		assertEquals(-2, score.scoreHand(p));
		c1 = new Card("Y");
		c2 = new Card("R");
		h.addCard(c1);
		h.addCard(c2);
		p.setPlayersHand(h);
		assertEquals(-14, score.scoreHand(p));
	}
	
	@Test
	public void TestGameConstructor(){
		ArrayList<String> players = new ArrayList<String>();
		players.add("Eric");
		Game onePlayer = new Game(1,players);
		assertEquals("Eric", onePlayer.getPlayers().get(0).getUserName());
		assertEquals(1,onePlayer.getPlayers().size());
		assertEquals(85,onePlayer.getDeck().size());
		assertEquals(16,onePlayer.getPlayers().get(0).getPlayersHand().size());
		assertEquals(1,onePlayer.getDiscardPile().size());
		
		players = new ArrayList<String>();
		players.add("Eric");
		players.add("Jim");
		Game twoPlayers = new Game(2,players);
		assertEquals("Eric", twoPlayers.getPlayers().get(0).getUserName());
		assertEquals("Jim", twoPlayers.getPlayers().get(1).getUserName());
		assertEquals(2,twoPlayers.getPlayers().size());
		assertEquals(77, twoPlayers.getDeck().size());
		assertEquals(12,twoPlayers.getPlayers().get(0).getPlayersHand().size());
		assertEquals(12,twoPlayers.getPlayers().get(1).getPlayersHand().size());
		assertEquals(1,twoPlayers.getDiscardPile().size());
		
		players = new ArrayList<String>();
		players.add("Eric");
		players.add("Jim");
		players.add("Corbino");
		Game threePlayers = new Game(3,players);
		assertEquals("Eric", threePlayers.getPlayers().get(0).getUserName());
		assertEquals("Jim", threePlayers.getPlayers().get(1).getUserName());
		assertEquals("Corbino", threePlayers.getPlayers().get(2).getUserName());
		assertEquals(3, threePlayers.getPlayers().size());
		assertEquals(71, threePlayers.getDeck().size());
		assertEquals(10,threePlayers.getPlayers().get(0).getPlayersHand().size());
		assertEquals(10,threePlayers.getPlayers().get(1).getPlayersHand().size());
		assertEquals(10,threePlayers.getPlayers().get(2).getPlayersHand().size());
		assertEquals(1,threePlayers.getDiscardPile().size());
		
		players = new ArrayList<String>();
		players.add("Eric");
		players.add("Jim");
		players.add("Corbino");
		players.add("Spencer");
		Game fourPlayers = new Game(4,players);
		assertEquals("Eric", fourPlayers.getPlayers().get(0).getUserName());
		assertEquals("Jim", fourPlayers.getPlayers().get(1).getUserName());
		assertEquals("Corbino", fourPlayers.getPlayers().get(2).getUserName());
		assertEquals("Spencer", fourPlayers.getPlayers().get(3).getUserName());
		assertEquals(4, fourPlayers.getPlayers().size());
		assertEquals(69, fourPlayers.getDeck().size());
		assertEquals(8,fourPlayers.getPlayers().get(0).getPlayersHand().size());
		assertEquals(8,fourPlayers.getPlayers().get(1).getPlayersHand().size());
		assertEquals(8,fourPlayers.getPlayers().get(2).getPlayersHand().size());
		assertEquals(8,fourPlayers.getPlayers().get(3).getPlayersHand().size());
		assertEquals(1,fourPlayers.getDiscardPile().size());
		
	}
}
